package pictogram.front;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;



public class EffectAdapter extends ArrayAdapter<EffectList> {
	
	int layoutResourceId;
	EffectList data[] = null;
	Context context;
	
	public EffectAdapter(Context context, int layoutResourceId, EffectList[] data)
	{
		super(context, layoutResourceId, data);
		
		this.layoutResourceId = layoutResourceId;
		this.context = context;
		this.data = data;		
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent)
	{
		View row = convertView;
		EffectHolder holder = null;
		
		if(row == null)
		{
			LayoutInflater inflater = ((Activity) context).getLayoutInflater();
			row = inflater.inflate(layoutResourceId, parent,false);
			
			holder = new EffectHolder();
			holder.imgIcon = (ImageView)row.findViewById(R.id.imgIcon);
			
			row.setTag(holder);
		}
		else
		{
			holder = (EffectHolder)row.getTag();
		}
		
		EffectList effect = data[position];
		holder.imgIcon.setImageResource(effect.icon);
		
		
		
		return row;
	}
	
	static class EffectHolder
	{
		ImageView imgIcon;
	}

}

